const Router = require('koa-router')
const router = new Router({ prefix: '/question' })
const jwt = require('koa-jwt')
const { find, findById, update, create, del,checkQuestioner, checkQuestionExist, listQuestionFollower } = require('../controlles/question')
const { secret } = require('../config')

const auth = jwt({ secret })
router.get('/', find)
router.get('/:id', checkQuestionExist,  findById)
router.post('/', auth,create)
router.patch('/:id', auth, checkQuestionExist, checkQuestioner,update)
router.delete('/:id', auth, checkQuestionExist, checkQuestioner,del)
router.get('/:id/follower', checkQuestionExist, listQuestionFollower)

module.exports = router